    def post(self):
    try:
        upload_files = self.get_uploads('file')  # 'file' is file upload field in the form
        if upload_files:
            blob_info = upload_files[0]  
    except:
        self.response.out.write('File not uploaded')        
    try:
        data = AForm(data=self.request.POST)
        if data and data.is_valid():
            # Save the data, and redirect to the view page
            entity = data.save(commit=False)
            entity.added_by = users.get_current_user()
            entity.put()
            if upload_files:            
                im = Image(reference=entity) 
                im.primary_image = blob_info.key()
                im.put()
                entity.put()
                self.redirect('/serve/%s' % blob_info.key())
        else:
            # Reprint the form
            self.response.out.write('<html><body>'
                                    '<form method="POST" '
                                    'action="/">'
                                    '<table>')
            self.response.out.write(data)
            self.response.out.write('</table>'
                                    '<input type="submit">'
                                    '</form></body></html>')
    except:
        self.redirect('/serve/%s' % blob_info.key())
        
#Another Snippet:
import os
import urllib

from google.appengine.ext import blobstore
from google.appengine.ext import webapp
from google.appengine.ext.webapp import blobstore_handlers
from google.appengine.ext.webapp import template
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db

class StoredFiles(db.Model):
    nickname = db.StringProperty()
    blobkey = blobstore.BlobReferenceProperty()
    
class UploadHandler(blobstore_handlers.BlobstoreUploadHandler):
    def post(self):
        try:
            upload_files = self.get_uploads('file')
            blob_info = upload_files[0]

            newFile = StoredFiles()
            newFile.nickname = self.request.get('nickname')
            newFile.blobkey = blob_info.key()
            newFile.put()

            self.redirect('/')
        except:
            self.redirect('/upload_failure.html')